package cn.test.rabbitmq.spring;

import cn.test.MqBean;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * @author hanchao
 * @date 2017/7/3 17:44
 */
public class MessageProducer {
    public static void main(String[] args) throws InterruptedException {
        ApplicationContext context = new FileSystemXmlApplicationContext("classpath:rabbitmq.xml");

        RabbitTemplate rabbitSender = context.getBean(RabbitTemplate.class);
        int i=0;
        for (;;){
            MqBean mqBean = new MqBean();
            mqBean.setAge(i++);
            mqBean.setName("i"+i);
            rabbitSender.convertAndSend("spring-queue-fa",mqBean);
            Thread.sleep(1000L);
            break;
        }
    }
}
